﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.App_Code;
using QXBook.Model;
using System.Configuration;
using QXBook.Utils;
using QXBook.Service;

namespace Web.SysManage.Orders
{
    public partial class OrderInfo : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(CommonUtils.Get("HeaderID")))
                {
                    hHeaderID.Value = CommonUtils.Get("HeaderID");
                    OrderHeaderInfo order = ServiceFactory.CreateInstance<OrderService>().GetOrderByOrderID(CommonUtils.ToInt(hHeaderID.Value));
                    this.DataBind(order);
                }
            }
        }

        private void DataBind(OrderHeaderInfo model)
        {
            sOrderCode.Text = model.OrderCode;
            sConsignee.Text = model.Consignee;
            sAddress.Text = model.Address;

            List<OrderItemInfo> list = ServiceFactory.CreateInstance<OrderService>().GetOrderItemByOrderID(CommonUtils.ToInt(hHeaderID.Value));
            rptList.DataSource = list;
            rptList.DataBind();
        }

    }
}